﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DeployGames.TweenEngine.equations
{
    public abstract class Expo : TweenEquation
    {
        public static ExpoIN IN = new ExpoIN();
        public static ExpoOUT OUT = new ExpoOUT();
        public static ExpoINOUT INOUT = new ExpoINOUT();

        #region ExpoIN
        public class ExpoIN : Expo
        {

            public override float compute(float t)
            {
                return (t == 0) ? 0 : (float)Math.Pow(2, 10 * (t - 1));
            }

            public override string ToString()
            {
                return "Expo.IN";
            }
        }
        #endregion

        #region ExpoOUT
        public class ExpoOUT : Expo
        {

            public override float compute(float t)
            {
                return (t == 1) ? 1 : -(float)Math.Pow(2, -10 * t) + 1;
            }

            public override string ToString()
            {
                return "Expo.OUT";
            }
        }
        #endregion

        #region ExpoINOUT
        public class ExpoINOUT : Expo
        {

            public override float compute(float t)
            {
                if (t == 0) return 0;
                if (t == 1) return 1;
                if ((t *= 2) < 1) return 0.5f * (float)Math.Pow(2, 10 * (t - 1));
                return 0.5f * (-(float)Math.Pow(2, -10 * --t) + 2);
            }

            public override string ToString()
            {
                return "Expo.INOUT";
            }
        }
        #endregion
    }
}
